package com.xiu.json.engine;

/**
 * @Author: tjc
 * @description
 * @Date Created in 0:21 2022-04-03
 */
public class StringLoader {
    final String str;

    private int length;
    private int next = 0;
    private int mark = 0;

    public StringLoader(String str) {
        this.str = str;
        this.length = str.length();
    }

    public char nextNotBlankC() {
        char c;
        for (; ; ) {
            c = nextc();
            if (!CharacterDef.blankChars.contains(c)) {
                return c;
            }
        }
    }

    public char nextc() {
        if (next >= length)
            return 0;
        char c = str.charAt(next++);
        return c;
    }

    public char backc() {
        if(next <= 0) {
            throw new UnsupportedOperationException("is already head for string.");
        }
        char c = str.charAt(--next);
        return c;
    }
}
